package Tools;

import javax.swing.*;
import java.util.concurrent.BlockingQueue;

/**
 * Created by IntelliJ IDEA.
 * User: leontiad
 * Date: Jul 22, 2010
 * Time: 4:30:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class MonitorThread extends Thread {
    protected BlockingQueue queue;
    protected JTextArea displayScreen;

    public MonitorThread(BlockingQueue queue, JTextArea displayScreen) {
        this.queue = queue;
        this.displayScreen = displayScreen;

    }

    public void run() {
        try {
            while (true) {
                Object obj = queue.take();
                displayScreen.append((String) obj);
                int len = queue.size();
                System.out.println("List size now " + len);
//                if (len == 0) {
//                    return ;
//                }

            }
        } catch (InterruptedException ex) {
            System.out.println("CONSUMER INTERRUPTED");
        }

    }
}
